 package net.ruixin.web.struts2.plugins;

 import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import java.io.PrintWriter;
 import javax.servlet.http.HttpServletResponse;
 import org.apache.struts2.dispatcher.StrutsResultSupport;

 public class StringResultType extends StrutsResultSupport
 {
   private static final long serialVersionUID = 1L;
   private String contentTypeName;
   private String stringName = "";

   public StringResultType() {
   }
   public StringResultType(String location) {
     super(location);
   }

   protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
     HttpServletResponse response = (HttpServletResponse)invocation.getInvocationContext().get("com.opensymphony.xwork2.dispatcher.HttpServletResponse");

     String contentType = conditionalParse(this.contentTypeName, invocation);
     if (contentType == null) {
       contentType = "text/plain; charset=UTF-8";
     }
     response.setContentType(contentType);
     PrintWriter out = response.getWriter();
     String result = conditionalParse(this.stringName, invocation);

     out.println(result);
     out.flush();
     out.close();
   }
   public String getContentTypeName() {
     return this.contentTypeName;
   }
   public void setContentTypeName(String contentTypeName) {
     this.contentTypeName = contentTypeName;
   }
   public String getStringName() {
     return this.stringName;
   }
   public void setStringName(String stringName) {
     this.stringName = stringName;
   }
 }
